public class Test {
    public static void main1(String[] args) {
        int[] array=null;
        System.out.println(array.length);
        /*   Exception in thread "main" java.lang.NullPointerException   */
        //空指针异常，不会执行下一句
        System.out.println("111111");
    }


    public static void test1(int[] a)throws CloneNotSupportedException
    {
        if(a==null)
        {
            throw new CloneNotSupportedException();
        }
    }
    public static void main2(String[] args) {
        //异常其实就是类
        //编译异常(受查异常)   会出现红线
        //运行异常(非受查异常)
      try{
            test1(null);
          }catch(CloneNotSupportedException e){
          e.printStackTrace();//打印异常
          System.out.println("捕获到 CloneNotSupportedException ！");
        }catch(Exception ex)
      {
          ex.printStackTrace();
          System.out.println("捕获到 NullPointerException 异常！");
      }
        System.out.println("完成捕获！");

    }


    public static void main(String[] args)  {
        try{
            int[] a=null;
            System.out.println(a.length);
        }catch(NullPointerException e){
            e.printStackTrace();//打印异常
            System.out.println("捕获到 NullPointerException ！");
        }catch(Exception ex)
        {
            ex.printStackTrace();
            System.out.println("捕获到 CloneNotSupportedException 异常！");
        }
        finally {
            System.out.println("finally 一般用于资源的释放！");
        }

        System.out.println("完成捕获！");

    }
}
